package com.yanqu.road.server.cmd.specialcookboy;

import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.specialcookboy.SpecialCookBoyProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.gameplayer.module.specialcookboy.SpecialCookBoyModule;
import com.yanqu.road.server.protocol.ClientProtocol;
import com.yanqu.road.server.protocol.GameProtocol;
import com.yanqu.road.server.protocol.Protocol;

import java.util.ArrayList;
import java.util.List;

@Cmd(code = GameProtocol.S_SPECIAL_COOK_BOY_FINISH_GUIDE,desc = "小当家特色服完成新手引导")
public class SpecialCookBoyFinishGuideCmd extends AbstractCommand {

    private List<Integer> steps = new ArrayList<>();

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        SpecialCookBoyProto.SpecialCookBoyFinishGuideReqMsg msg = SpecialCookBoyProto.SpecialCookBoyFinishGuideReqMsg.parseFrom(packet.getBytes());
        steps = msg.getStepList();
        return true;
    }

    @Override
    public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
        ret = player.getModule(SpecialCookBoyModule.class).finishGuide(steps);
    }

    @Override
    public void sendData(GamePlayer player) {
        if (ret != 0){
            SpecialCookBoyProto.SpecialCookBoyFinishGuideRespMsg.Builder respMsg = SpecialCookBoyProto.SpecialCookBoyFinishGuideRespMsg.newBuilder();
            respMsg.setRet(ret);
            player.sendPacket(ClientProtocol.U_SPECIAL_COOK_BOY_FINISH_GUIDE, respMsg);
        }
    }
}
